package com.huike.pmps.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huike.pmps.model.entity.POCourseSupplierDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 作者：谌贵斌(黑桃K)
 * 日期: 2888-08-08
 * 老师QQ: 272488352
 * 官方QQ交流群: 377748272
 * 刀客程序员官网：http://www.daoke360.com
 * 刀客程序员淘宝旗舰店：https://daoke360.taobao.com/
 */
public interface POCourseSupplierDetailDao extends BaseMapper<POCourseSupplierDetail> {

 /*   //批量更新
    @Update({
            "<script>",
            "<foreach collection='list' item='item' index='index' separator=';'>",
            "update p_po_course_supplier_detail pd",
            "set state = #{item.state}  where id= #{item.id}",
            "</foreach>",
            "</script>"
    })
    int updateStateById(List<POCourseSupplierDetail> list);*/

    @Insert({
            "<script>",
            "insert into p_po_course_supplier_detail(",
            "  po_course_id,                         ",
            "  po_id,                                ",
            "  po,                                   ",
            "  po_contract_amount,                   ",
            "  customer_name,                        ",
            "  region_id,                            ",
            "  region_name,                          ",
            "  province_id,                          ",
            "  province_name,                        ",
            "  course_charge_id,                     ",
            "  course_charge_name,                   ",
            "  course_id,                            ",
            "  course_name,                          ",
            "  subject_category_id,                  ",
            "  subject_category_name,                ",
            "  major_category,                       ",
            "  shoot_mode_id,                        ",
            "  shoot_mode_name,                      ",
            "  supplier_type_id,                     ",
            "  supplier_type_name,                   ",
            "  supplier_id,                          ",
            "  supplier_name,                        ",
            "  service_type_id,                      ",
            "  service_type_name,                    ",
            "  service_name,                         ",
            "  estimated_settlement_date,            ",
            "  unit_price,                           ",
            "  quantity,                             ",
            "  estimated_generation_cost,            ",
            "  supplier_paid_amount,                 ",
            "  supplier_unpaid_amount,               ",
            "  final_evaluation,                     ",
            "  description,                          ",
            "  acceptance_report_path,               ",
            "  import_flag,                          ",
            "  import_course_id,                     ",
            "  import_service_id,                    ",
            "  state,                                ",
            "  row_edit,                             ",
            "  update_time,                          ",
            "  create_time                           ",
            ") values                                ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(									",
            "   #{item.poCourseId},             ",
            "   #{item.poId},                   ",
            "   #{item.po},                     ",
            "   #{item.poContractAmount},       ",
            "   #{item.customerName},           ",
            "   #{item.regionId},               ",
            "   #{item.regionName},             ",
            "   #{item.provinceId},             ",
            "   #{item.provinceName},           ",
            "   #{item.courseChargeId},         ",
            "   #{item.courseChargeName},       ",
            "   #{item.courseId},               ",
            "   #{item.courseName},             ",
            "   #{item.subjectCategoryId},      ",
            "   #{item.subjectCategoryName},    ",
            "   #{item.majorCategory},          ",
            "   #{item.shootModeId},            ",
            "   #{item.shootModeName},          ",
            "   #{item.supplierTypeId},         ",
            "   #{item.supplierTypeName},       ",
            "   #{item.supplierId},             ",
            "   #{item.supplierName},           ",
            "   #{item.serviceTypeId},          ",
            "   #{item.serviceTypeName},        ",
            "   #{item.serviceName},            ",
            "   #{item.estimatedSettlementDate},",
            "   #{item.unitPrice},              ",
            "   #{item.quantity},               ",
            "   #{item.estimatedGenerationCost},",
            "   #{item.supplierPaidAmount},     ",
            "   #{item.supplierUnpaidAmount},   ",
            "   #{item.finalEvaluation},        ",
            "   #{item.description},            ",
            "   #{item.acceptanceReportPath},   ",
            "   #{item.importFlag},             ",
            "   #{item.importCourseId},         ",
            "   #{item.importServiceId},        ",
            "   #{item.state},                  ",
            "   #{item.rowEdit},                ",
            "   #{item.updateTime},             ",
            "   #{item.createTime}              ",
            "  )                                ",
            "</foreach>",
            "</script>"
    })
    int insertBatchList(List<POCourseSupplierDetail> list);


    //批量更新
    @Update({
            "<script>",
            "<foreach collection='list' item='item' index='index' separator=';'>",
            "update p_po_course_supplier_detail set state=1 where id=#{item}",
            "</foreach>",
            "</script>"
    })
    int updateBatchList(List<Integer> list);
}
